<%@ include file="/WEB-INF/jsp/includes.jsp" %>
<c:choose>
	<c:when test="${news.new}"><c:set var="method" value="post"/></c:when>
	<c:otherwise><c:set var="method" value="put"/></c:otherwise>
</c:choose>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>浙江孵化器在线后台管理系统</title>
        <link href="<spring:url value="/static/style/index.css" htmlEscape="true" />" rel="stylesheet" type="text/css">
        <script type="text/javascript" src="<spring:url value="/static/js/jquery.min.js" htmlEscape="true" />"></script>
        <%@include file="/WEB-INF/jsp/inc/calendar.jsp"%>
    </head>
    <body>
        <div class="list_right_title">
        	<span><img src="<spring:url value="/static/images/im.jpg" htmlEscape="true" />" alt="信息管理"></span>光伏在线>>光伏产业>>添加
        </div>
		<div class="fhq_add">
			<div class="fhq_add_in">
				<div class="fhq_add_form">
                    <form:form modelAttribute="news" method="${method}" enctype="multipart/form-data">
                    <form:hidden path="id"/>
						<table class="fhq_add_table" cellpadding="0" cellspacing="" summary="光伏在线>>光伏产业>>添加">
                            <tr>
                                <th width="20%">标题：</th>
                                <td width="80%">
                                    <form:input path="title" cssClass="add_form_input"/>
                                <form:errors path="title" cssClass="error" />
                                </td>
                            </tr>
            <tr>
                <th>图片：</th>
                <td>
                    <c:if test="${news.imageName != null}">
                        <img width="284" src="<spring:url value="/static/upload/news/${news.id}/${news.imageName}?r=${random}" htmlEscape="true" />" alt="图片">
                    </c:if>
                    <input name="image" type="file">
                </td>
            </tr>
                            <tr>
                                <th>附件：</th>
                                <td>
                                    <c:forEach items="${news.attachmentList}" var="attachment" varStatus="status">
                                        ${attachment.name} <input type="button" value="删除" onclick="toDeleteAttachment(this, '${attachment.id}');"/>
                                    </c:forEach>
                                </td>
                                <script type="text/javascript">
                                    function toDeleteAttachment(el, attachmentId) {
                                        if (el.value == "删除") {
                                            el.value = "恢复";
                                            var hiddenInput = document.createElement("INPUT");
                                            hiddenInput.id = "delAttachmentIds_"+ attachmentId;
                                            hiddenInput.type = "hidden";
                                            hiddenInput.name = "delAttachmentIds";
                                            hiddenInput.value = attachmentId;
                                            document.getElementById("delIdsContainer").appendChild(hiddenInput);
                                        } else {
                                            el.value = "删除";
                                            el.name = "attachmentList.id"
                                            var hiddenInput = document.getElementById("delAttachmentIds_"+ attachmentId);
                                            document.getElementById("delIdsContainer").removeChild(hiddenInput);
                                        }
                                    }
                                    function toAddAttachment() {
                                        var firstAttachmentContainer = document.getElementById("firstAttachmentContainer");
                                        var newAttachmentContainer = document.createElement("P");
                                        firstAttachmentContainer.parentNode.appendChild(newAttachmentContainer);
                                        newAttachmentContainer.innerHTML='<input type="file" name="attachments" class="add_form_annex"><br/>附件大小不得大于5M 格式： TXT\\DOC\\ZIP\\RAR\\XLS\\JPG\\GIF，务必命名正确的附件名称';
                                    }
                                </script>
                            </tr>
                            <tr style="display:none">
                                <td colspan="2" id="delIdsContainer">
                                    <input type="hidden" name="delAttachmentIds" value="-1"/>
                                </td>
                            </tr>
                            <tr>
                                <th>附件：</th>
                                <td><input type="button" value="增加附件" onclick="toAddAttachment()"/></td>
                            </tr>
                            <tr>
                                <th style="padding-bottom:30px;">&nbsp;</th>
                                <td style="line-height:15px; color:#b6b6b6;">
                                    <p id="firstAttachmentContainer">
                                    <input type="file" name="attachments" class="add_form_annex">
                                    <br/>附件大小不得大于5M 格式： TXT\DOC\ZIP\RAR\XLS\JPG\GIF，务必命名正确的附件名称
                                    </p>
                                </td>
                            </tr>
                            <tr>
                                <th>发布时间：</th>
                                <td>
                                    <form:input path="publishDate" cssClass="fhq_add_select"/> 发布状态：
                                    <form:select path="publishStatus" items="${allPublishStatus}" cssClass="fhq_add_select"/>
                                </td>
                            </tr>
                            <tr>
                                <th>来源：</th>
                                <td>
                                    <form:input path="src"/>
                                    显示位置：
                                    <form:select items="${allPositions}" path="position" cssClass="fhq_add_select"/>
                                </td>
                            </tr>
                            <tr>
                                <th>文章类型：</th>
                                <td>
                                    <form:select items="${allCategories}" path="category"/>
                                </td>
                            </tr>
                            <tr>
                                <th>摘要：</th>
                                <td>
                                    <form:textarea path="summary" rows="3" cols="135"/>
                                </td>
                            </tr>
                            <tr>
                                <th>文章正文：</th>
                                <td>
                                    <FCK:editor instanceName="EditorDefault" inputName="content" height="500"  value="${news.content}">
                                    </FCK:editor>
                                </td>
                            </tr>
                            <tr>
                                <th>权值：</th>
                                <td>
                                    <form:input path="orderCode"/>
                                </td>
                            </tr>
							<tr>
								<th>发布人：</th>
								<td>
									admin
								</td>
							</tr>
							<tr>
								<th>&nbsp;</th>
								<td style="padding-top:20px;">
									<!--<input type="button" value=" 保存并报送 ">　　　-->
                                    <input type="submit" value=" 保存 ">　　　
                                    <input type="button" value=" 返回 "  onclick="window.location.href='search'">
								</td>
							</tr>
						</table>
					</form:form>
				</div>
			</div>
		</div>
    </body>
</html>